package com.ruix.app.ui.adapter;

import android.content.Context;
import android.view.View;

import com.ruix.app.R;
import com.ruix.app.adapter.superadapter.SuperAdapter;
import com.ruix.app.adapter.superadapter.internal.SuperViewHolder;
import com.ruix.app.model.viewmodel.InputSubItem;
import com.ruix.app.util.LogUitl;

/**
 * Created by hadexs on 2017/5/17.
 */

public class LessonInputViewAdapter extends SuperAdapter<InputSubItem>{


    private OnItemClickLisenter onClickLisenter;
    private boolean muted;

    public LessonInputViewAdapter(Context context,OnItemClickLisenter lisenter) {
        super(context, R.layout.item_lesson_send_message_add);
        onClickLisenter = lisenter;
    }

    @Override
    public void onBind(SuperViewHolder holder, int viewType, int position, final InputSubItem item) {
        if (item.getId() == 1){
            if (muted){
                holder.setImageViewSrc(R.id.iv_other_btn,item.getIamgeActionResorce());
                holder.setText(R.id.tv_other_btn_name,item.getNameActionResorce());
            } else {
                holder.setImageViewSrc(R.id.iv_other_btn,item.getImageResorce());
                holder.setText(R.id.tv_other_btn_name,item.getNameResorce());
            }
        } else {
            holder.setImageViewSrc(R.id.iv_other_btn,item.getImageResorce());
            holder.setText(R.id.tv_other_btn_name,item.getNameResorce());
        }

        holder.setOnClickListener(R.id.item_contain, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onClickLisenter != null){
                    onClickLisenter.onItemClicked(item);
                }
            }
        });

    }

    public void setMuted(boolean muted) {
        this.muted = muted;
    }

    public  interface OnItemClickLisenter{
        void onItemClicked(InputSubItem inputSubItem);
    }

}
